package com.hj.lib.util;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.file.FileWriter;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class LogUtil {

	public static void debug(String tag,String log) {

		String pathTemp = tag+DateUtil.today()+"".replaceAll(" ", "_");
		pathTemp = pathTemp.replaceAll("-", "_");
		String logPath = "C:\\hjlog\\"+pathTemp+".txt";
		System.out.println(logPath);
		File file = new File(logPath);
		File dir = new File("C:\\hjlog\\");
		if (!dir.exists()) {
			dir.mkdirs();
		}
		if (!file.exists()) {
			try {
				file.createNewFile();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		FileWriter writer = new FileWriter(logPath);
		log = log + "---->" + DateUtil.now();
		List<String> list = new ArrayList<String>();
		list.add(log);
		writer.appendLines(list);
	}

}
